{include file="public/header" /}
<!--main content start-->
<section class="main-content-wrapper">
    <section id="main-content">
        <div class="row">
        <div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading">
                    <h3 class="panel-title">商品添加/修改</h3>
                </div>
                <div class="panel-body">
                <form action="/admin/sale/sale_save" method="post" enctype="multipart/form-data" class="form-horizontal form-border">
                    <input name="id" value="{$id|default=''}" type="hidden">
                    <div class="form-group">
                        <label class="col-sm-2 control-label">商品标题：</label>
                        <div class="col-sm-4">
                            <input type="text" class="form-control" id="title" name="title" autocomplete="off" value="{$title|default=''}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">SEO描述：</label>
                        <div class="col-sm-4">
                            <textarea class="form-control" name="seo_description">{$seo_description|default=''}</textarea>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">价格：</label>
                        <div class="col-sm-2">
                            <input type="text" class="form-control" name="n_price" placeholder="现价" value="{$n_price|default=''}">
                        </div>
                        <div class="col-sm-2">
                            <input type="text" class="form-control" name="y_price" placeholder="原价" value="{$y_price|default=''}">
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">商品图片：</label>
                        <div class="col-sm-2">
                            <input type="file" name="image_f" id="imgOne1" onchange="preImg(this.id,'imgPre1');" />
                            <p class="help-block">建议尺寸150*100.</p>
                            <img id="imgPre1" src="{$image_f|default='/web_admin/img/nopic.png'}" width="150px" height="100px" style="display: block;" />
                        </div>
                        <div class="col-sm-2">
                            <input type="file" name="image_s" id="imgOne2" onchange="preImg(this.id,'imgPre2');" />
                            <p class="help-block">建议尺寸150*100.</p>
                            <img id="imgPre2" src="{$image_s|default='/web_admin/img/nopic.png'}" width="150px" height="100px" style="display: block;" />
                        </div>
                        <div class="col-sm-2">
                            <input type="file" name="image_t" id="imgOne3" onchange="preImg(this.id,'imgPre3');" />
                            <p class="help-block">建议尺寸150*100.</p>
                            <img id="imgPre3" src="{$image_t|default='/web_admin/img/nopic.png'}" width="150px" height="100px" style="display: block;" />
                        </div>
                    </div>

                    <div class="form-group">
                        <label class="col-sm-2 control-label label-input-sm">商品描述：</label>
                        <div class="col-sm-8">
                            <script id="editor" type="text/plain" style="width:500px;height:200px;" name="description">{$description|default=''}</script>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label label-input-sm">使用方法：</label>
                        <div class="col-sm-8">
                            <script id="editor1" type="text/plain" style="width:500px;height:300px;" name="instructions">{$instructions|default=''}</script>
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">付款方式：</label>
                        <div class="col-sm-2">
                            <input name="pay_type" value="1" type="radio"  checked>货到付款&nbsp;&nbsp;
                            <input name="pay_type" type="radio" value="2" {if isset($pay_type)}{if condition="($pay_type == 2)"} checked {else /}{/if}{else /}{/if}} disabled>在线支付
                        </div>
                    </div>
                    <div class="form-group">
                        <label class="col-sm-2 control-label">是否上架：</label>
                        <div class="col-sm-2">
                            <input name="status" value="1" type="radio"  {if isset($status)}{if condition="($status == 1)"} checked {else /}{/if}{else /}{/if}}>是&nbsp;&nbsp;
                            <input name="status" type="radio" value="2" {if isset($status)}{if condition="($status == 2)"} checked {else /}{/if}{else /}{/if}}>否
                        </div>
                    </div>
                    <div class="panel-body">
                        <button type="submit" class="btn btn_5 btn-lg btn-default w_update">发布</button>
                    </div>
                </form>
                </div>
            </div>
        </div>
        </div>
    </section>
</section>
<style>
    @media (min-width: 768px){
        .form-horizontal .control-label {
             text-align: left;
        }
    }
</style>

<!--百度编辑器插件-->
<script type="text/javascript" charset="utf-8" src="/web_admin/ueditor/ueditor.config.js"></script>
<script type="text/javascript" charset="utf-8" src="/web_admin/ueditor/ueditor.all.min.js"> </script>
<!--建议手动加在语言，避免在ie下有时因为加载语言失败导致编辑器加载失败-->
<!--这里加载的语言文件会覆盖你在配置项目里添加的语言类型，比如你在配置项目里配置的是英文，这里加载的中文，那最后就是中文-->
<script type="text/javascript" charset="utf-8" src="/web_admin/ueditor/lang/zh-cn/zh-cn.js"></script>

<!--时间插件-->
<script src="/web_admin/js/bootstrap-datetimepicker.min.js"></script>
<link href="/web_admin/css/datetimepicker.css" rel='stylesheet' type='text/css' />
<script>
    //实例化编辑器
    //建议使用工厂方法getEditor创建和引用编辑器实例，如果在某个闭包下引用该编辑器，直接调用UE.getEditor('editor')就能拿到相关的实例
    var ue = UE.getEditor('editor');
    var ue = UE.getEditor('editor1');
</script>
<script>
    /**
     * 从 file 域获取 本地图片 url
     */
    function getFileUrl(sourceId) {
        var url;
        if (navigator.userAgent.indexOf("MSIE")>=1) { // IE
            url = document.getElementById(sourceId).value;
        } else if(navigator.userAgent.indexOf("Firefox")>0) { // Firefox
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        } else if(navigator.userAgent.indexOf("Chrome")>0) { // Chrome
            url = window.URL.createObjectURL(document.getElementById(sourceId).files.item(0));
        }
        return url;
    }
    /**
     * 将本地图片 显示到浏览器上
     */
    function preImg(sourceId, targetId) {
        var url = getFileUrl(sourceId);
        var imgPre = document.getElementById(targetId);
        imgPre.src = url;
    }
</script>
<!--main content end-->
{include file="public/footer" /}